package com.zhangcuishan.blog.util;

import okhttp3.OkHttpClient;
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

public class EventStreamRestTemplate extends RestTemplate {

    private final OkHttpClient client;

    public EventStreamRestTemplate() {
        this.client = new OkHttpClient().newBuilder()
                .addInterceptor(chain -> chain.proceed(chain.request()))
                .build();
        this.setRequestFactory(new OkHttp3ClientHttpRequestFactory(client));
    }
}